import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

/**
 * roleService - 角色管理service
 * @date: 2018-7-24

 */
import qs from 'querystring';
import request from 'utils/request';
import { CPAAS_IAM, CPAAS_PLATFORM } from 'utils/config';

function enableStatus(status) {
  return status ? 'enable' : 'disable';
}
/**
 * 查询分配给当前登录用户的角色
 * @async
 * @function queryAdminRoles
 * @param {object} params - 查询条件
 * @returns {object} fetch Promise
 */


export function queryAdminRoles() {
  return _queryAdminRoles.apply(this, arguments);
}
/**
 * 查询管理员用户所创建的角色子树
 * @async
 * @function queryCreateRolesSubtree
 * @param {!number} parentRoleId - 角色(父)ID
 * @returns {object} fetch Promise
 */

function _queryAdminRoles() {
  _queryAdminRoles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
    var params,
        _args = arguments;
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
            return _context.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/member-roles/self"), {
              query: params
            }));

          case 2:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _queryAdminRoles.apply(this, arguments);
}

export function queryCreateRolesSubtree(_x) {
  return _queryCreateRolesSubtree.apply(this, arguments);
}
/**
 * 查询用户所拥有的全部角色，包括被直接授予的，以及间接继承的
 * @async
 * @function queryInheritRolesTree
 * @param {object} params - 查询条件
 * @param {?number} params.userId - 用户ID
 * @returns {object} fetch Promise
 */

function _queryCreateRolesSubtree() {
  _queryCreateRolesSubtree = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(parentRoleId) {
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            return _context2.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/member-roles/create-roles-subtree/").concat(parentRoleId)));

          case 1:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));
  return _queryCreateRolesSubtree.apply(this, arguments);
}

export function queryInheritRolesTree() {
  return _queryInheritRolesTree.apply(this, arguments);
}
/**
 * 查询值集
 * @async
 * @function queryCode
 * @param {object} params - 查询条件
 * @param {!string} param.lovCode - 查询条件
 * @returns {object} fetch Promise
 */

function _queryInheritRolesTree() {
  _queryInheritRolesTree = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
    var params,
        _args3 = arguments;
    return _regeneratorRuntime.wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            params = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
            return _context3.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/member-roles/inherit-roles-tree"), {
              query: params
            }));

          case 2:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3);
  }));
  return _queryInheritRolesTree.apply(this, arguments);
}

export function queryCode() {
  return _queryCode.apply(this, arguments);
}
/**
 * 查询值集
 * @async
 * @function queryCode
 * @param {!number} id - 角色ID
 * @param {!boolean} [status=false] - 启用或停用
 * @returns {object} fetch Promise
 */

function _queryCode() {
  _queryCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
    var params,
        _args4 = arguments;
    return _regeneratorRuntime.wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            params = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
            return _context4.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/lovs/value"), {
              query: params
            }));

          case 2:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4);
  }));
  return _queryCode.apply(this, arguments);
}

export function enableRole(_x2) {
  return _enableRole.apply(this, arguments);
}
/**
 * 通过类型查询label
 * @async
 * @function queryLabels
 * @param {object} params - 角色ID
 * @param {!boolean} [status=false] - 启用或停用
 * @returns {object} fetch Promise
 */

function _enableRole() {
  _enableRole = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref) {
    var id, status;
    return _regeneratorRuntime.wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            id = _ref.id, status = _ref.status;
            return _context5.abrupt("return", request("".concat(CPAAS_IAM, "/v1/roles/").concat(id, "/").concat(enableStatus(status)), {
              method: 'PUT'
            }));

          case 2:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5);
  }));
  return _enableRole.apply(this, arguments);
}

export function queryLabels(_x3) {
  return _queryLabels.apply(this, arguments);
}
/**
 * 通过id查询角色
 * @async
 * @function queryRole
 * @param {!number} roleId - 角色ID
 * @returns {object} fetch Promise
 */

function _queryLabels() {
  _queryLabels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(params) {
    return _regeneratorRuntime.wrap(function _callee6$(_context6) {
      while (1) {
        switch (_context6.prev = _context6.next) {
          case 0:
            return _context6.abrupt("return", request("".concat(CPAAS_IAM, "/v1/labels"), {
              query: params
            }));

          case 1:
          case "end":
            return _context6.stop();
        }
      }
    }, _callee6);
  }));
  return _queryLabels.apply(this, arguments);
}

export function queryRole(_x4) {
  return _queryRole.apply(this, arguments);
}
/**
 * 分页查询角色对应层级的权限
 * @deprecated 弃用,API已调整
 * @async
 * @function queryPermissions
 * @param {!number} roleId - 角色ID
 * @param {object} params - 查询条件
 * @param {!number} [params.page = 0] - 数据页码
 * @param {!number} [params.size = 10] - 分页大小
 * @returns {object} fetch Promise
 */

function _queryRole() {
  _queryRole = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(roleId) {
    return _regeneratorRuntime.wrap(function _callee7$(_context7) {
      while (1) {
        switch (_context7.prev = _context7.next) {
          case 0:
            return _context7.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/roles/").concat(roleId)));

          case 1:
          case "end":
            return _context7.stop();
        }
      }
    }, _callee7);
  }));
  return _queryRole.apply(this, arguments);
}

export function queryPermissions(_x5) {
  return _queryPermissions.apply(this, arguments);
}
/**
 * 分页查询角色对应层级的权限
 * @deprecated 弃用,API已调整
 * @async
 * @function queryOrganizationPermissions
 * @param {!number} roleId - 角色ID
 * @param {!number} organizationId - 组织ID
 * @param {object} params - 查询条件
 * @param {!number} [params.page = 0] - 数据页码
 * @param {!number} [params.size = 10] - 分页大小
 * @returns {object} fetch Promise
 */

function _queryPermissions() {
  _queryPermissions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(roleId) {
    return _regeneratorRuntime.wrap(function _callee8$(_context8) {
      while (1) {
        switch (_context8.prev = _context8.next) {
          case 0:
            return _context8.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/permissions/").concat(roleId)));

          case 1:
          case "end":
            return _context8.stop();
        }
      }
    }, _callee8);
  }));
  return _queryPermissions.apply(this, arguments);
}

export function queryOrganizationPermissions(_x6, _x7) {
  return _queryOrganizationPermissions.apply(this, arguments);
}
/**
 * 分页查询角色对应层级的权限
 * @async
 * @function queryLevelPermissions
 * @param {!number} roleId - 角色ID
 * @param {object} params - 查询条件
 * @param {!number} [params.page = 0] - 数据页码
 * @param {!number} [params.size = 10] - 分页大小
 * @returns {object} fetch Promise
 */

function _queryOrganizationPermissions() {
  _queryOrganizationPermissions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(roleId, organizationId) {
    return _regeneratorRuntime.wrap(function _callee9$(_context9) {
      while (1) {
        switch (_context9.prev = _context9.next) {
          case 0:
            return _context9.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(organizationId, "/permissions/").concat(roleId)));

          case 1:
          case "end":
            return _context9.stop();
        }
      }
    }, _callee9);
  }));
  return _queryOrganizationPermissions.apply(this, arguments);
}

export function queryLevelPermissions(_x8, _x9) {
  return _queryLevelPermissions.apply(this, arguments);
}
/**
 * 分页查询角色对应层级的权限 - 租户级
 * @async
 * @function queryOrganizationLevelPermissions
 * @param {!number} roleId - 角色ID
 * @param {!number} organizationId - 组织ID
 * @param {object} params - 查询条件
 * @param {!number} [params.page = 0] - 数据页码
 * @param {!number} [params.size = 10] - 分页大小
 * @returns {object} fetch Promise
 */

function _queryLevelPermissions() {
  _queryLevelPermissions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(roleId, level) {
    var params,
        _args10 = arguments;
    return _regeneratorRuntime.wrap(function _callee10$(_context10) {
      while (1) {
        switch (_context10.prev = _context10.next) {
          case 0:
            params = _args10.length > 2 && _args10[2] !== undefined ? _args10[2] : {};
            return _context10.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/permissions/").concat(roleId), {
              query: params
            }));

          case 2:
          case "end":
            return _context10.stop();
        }
      }
    }, _callee10);
  }));
  return _queryLevelPermissions.apply(this, arguments);
}

export function queryOrganizationLevelPermissions(_x10, _x11) {
  return _queryOrganizationLevelPermissions.apply(this, arguments);
}
/**
 * 查询所有已分配给角色的权限
 * @async
 * @function queryPermissionsAll
 * @param {!number} roleId - 角色ID
 * @returns {object} fetch Promise
 */

function _queryOrganizationLevelPermissions() {
  _queryOrganizationLevelPermissions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(roleId, level) {
    var params,
        organizationId,
        _args11 = arguments;
    return _regeneratorRuntime.wrap(function _callee11$(_context11) {
      while (1) {
        switch (_context11.prev = _context11.next) {
          case 0:
            params = _args11.length > 2 && _args11[2] !== undefined ? _args11[2] : {};
            organizationId = _args11.length > 3 ? _args11[3] : undefined;
            return _context11.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(organizationId, "/permissions/").concat(roleId), {
              query: params
            }));

          case 3:
          case "end":
            return _context11.stop();
        }
      }
    }, _callee11);
  }));
  return _queryOrganizationLevelPermissions.apply(this, arguments);
}

export function queryPermissionsAll(_x12) {
  return _queryPermissionsAll.apply(this, arguments);
}
/**
 * 查询所有已分配给角色的权限 - 租户级
 * @async
 * @function queryOrganizationPermissionsAll
 * @param {!number} roleId - 角色ID
 * @param {!number} organizationId - 组织ID
 * @returns {object} fetch Promise
 */

function _queryPermissionsAll() {
  _queryPermissionsAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(roleId) {
    return _regeneratorRuntime.wrap(function _callee12$(_context12) {
      while (1) {
        switch (_context12.prev = _context12.next) {
          case 0:
            return _context12.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/permissions/all/").concat(roleId)));

          case 1:
          case "end":
            return _context12.stop();
        }
      }
    }, _callee12);
  }));
  return _queryPermissionsAll.apply(this, arguments);
}

export function queryOrganizationPermissionsAll(_x13, _x14) {
  return _queryOrganizationPermissionsAll.apply(this, arguments);
}
/**
 * 查询角色已收回的权限
 * @async
 * @function queryOrganizationPermissionsAll
 * @param {!number} roleId - 角色ID
 * @param {object} params - 查询条件
 * @param {!number} [params.page = 0] - 数据页码
 * @param {!number} [params.size = 10] - 分页大小
 * @returns {object} fetch Promise
 */

function _queryOrganizationPermissionsAll() {
  _queryOrganizationPermissionsAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(roleId, organizationId) {
    return _regeneratorRuntime.wrap(function _callee13$(_context13) {
      while (1) {
        switch (_context13.prev = _context13.next) {
          case 0:
            return _context13.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(organizationId, "/permissions/all/").concat(roleId)));

          case 1:
          case "end":
            return _context13.stop();
        }
      }
    }, _callee13);
  }));
  return _queryOrganizationPermissionsAll.apply(this, arguments);
}

export function queryRevokedPermissionsAll(_x15, _x16) {
  return _queryRevokedPermissionsAll.apply(this, arguments);
}
/**
 * 查询角色已收回的权限 - 租户级
 * @async
 * @function queryOrganizationRevokedPermissionsAll
 * @param {!number} roleId - 角色ID
 * @param {!number} organizationId - 组织ID
 * @param {object} params - 查询条件
 * @param {!number} [params.page = 0] - 数据页码
 * @param {!number} [params.size = 10] - 分页大小
 * @returns {object} fetch Promise
 */

function _queryRevokedPermissionsAll() {
  _queryRevokedPermissionsAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(roleId, params) {
    return _regeneratorRuntime.wrap(function _callee14$(_context14) {
      while (1) {
        switch (_context14.prev = _context14.next) {
          case 0:
            return _context14.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/permissions/revoked/all/").concat(roleId), {
              query: params
            }));

          case 1:
          case "end":
            return _context14.stop();
        }
      }
    }, _callee14);
  }));
  return _queryRevokedPermissionsAll.apply(this, arguments);
}

export function queryOrganizationRevokedPermissionsAll(_x17, _x18, _x19) {
  return _queryOrganizationRevokedPermissionsAll.apply(this, arguments);
}
/**
 * 创建角色
 * @async
 * @function createRole
 * @param {!object} params - 保存参数
 * @returns {object} fetch Promise
 */

function _queryOrganizationRevokedPermissionsAll() {
  _queryOrganizationRevokedPermissionsAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(roleId, params, organizationId) {
    return _regeneratorRuntime.wrap(function _callee15$(_context15) {
      while (1) {
        switch (_context15.prev = _context15.next) {
          case 0:
            return _context15.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(organizationId, "/permissions/revoked/all/").concat(roleId), {
              query: params
            }));

          case 1:
          case "end":
            return _context15.stop();
        }
      }
    }, _callee15);
  }));
  return _queryOrganizationRevokedPermissionsAll.apply(this, arguments);
}

export function createRole(_x20) {
  return _createRole.apply(this, arguments);
}
/**
 * 创建角色 - 租户级
 * @async
 * @function createOrganizationRole
 * @param {!number} organizationId - 组织ID
 * @param {!object} params - 保存参数
 * @returns {object} fetch Promise
 */

function _createRole() {
  _createRole = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(params) {
    return _regeneratorRuntime.wrap(function _callee16$(_context16) {
      while (1) {
        switch (_context16.prev = _context16.next) {
          case 0:
            return _context16.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/roles"), {
              method: 'POST',
              body: params
            }));

          case 1:
          case "end":
            return _context16.stop();
        }
      }
    }, _callee16);
  }));
  return _createRole.apply(this, arguments);
}

export function createOrganizationRole(_x21, _x22) {
  return _createOrganizationRole.apply(this, arguments);
}
/**
 * 修改角色
 * @async
 * @function editRole
 * @param {!object} params - 保存参数
 * @returns {object} fetch Promise
 */

function _createOrganizationRole() {
  _createOrganizationRole = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(params, organizationId) {
    return _regeneratorRuntime.wrap(function _callee17$(_context17) {
      while (1) {
        switch (_context17.prev = _context17.next) {
          case 0:
            return _context17.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(organizationId, "/roles"), {
              method: 'POST',
              body: params
            }));

          case 1:
          case "end":
            return _context17.stop();
        }
      }
    }, _callee17);
  }));
  return _createOrganizationRole.apply(this, arguments);
}

export function editRole(_x23) {
  return _editRole.apply(this, arguments);
}
/**
 * 修改角色 - 租户级
 * @async
 * @function editOrganizationRole
 * @param {!number} organizationId - 组织ID
 * @param {!object} params - 保存参数
 * @returns {object} fetch Promise
 */

function _editRole() {
  _editRole = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(params) {
    return _regeneratorRuntime.wrap(function _callee18$(_context18) {
      while (1) {
        switch (_context18.prev = _context18.next) {
          case 0:
            return _context18.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/roles"), {
              method: 'PUT',
              body: params
            }));

          case 1:
          case "end":
            return _context18.stop();
        }
      }
    }, _callee18);
  }));
  return _editRole.apply(this, arguments);
}

export function editOrganizationRole(_x24, _x25) {
  return _editOrganizationRole.apply(this, arguments);
}
/**
 * 复制并创建角色
 * @async
 * @function copyRole
 * @param {!object} params - 保存参数
 * @returns {object} fetch Promise
 */

function _editOrganizationRole() {
  _editOrganizationRole = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(params, organizationId) {
    return _regeneratorRuntime.wrap(function _callee19$(_context19) {
      while (1) {
        switch (_context19.prev = _context19.next) {
          case 0:
            return _context19.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(organizationId, "/roles"), {
              method: 'PUT',
              body: params
            }));

          case 1:
          case "end":
            return _context19.stop();
        }
      }
    }, _callee19);
  }));
  return _editOrganizationRole.apply(this, arguments);
}

export function copyRole(_x26) {
  return _copyRole.apply(this, arguments);
}
/**
 * 复制并创建角色 - 租户级
 * @async
 * @function copyOrganizationRole
 * @param {!number} organizationId - 组织ID
 * @param {!object} params - 保存参数
 * @returns {object} fetch Promise
 */

function _copyRole() {
  _copyRole = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(params) {
    return _regeneratorRuntime.wrap(function _callee20$(_context20) {
      while (1) {
        switch (_context20.prev = _context20.next) {
          case 0:
            return _context20.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/roles/copy"), {
              method: 'POST',
              body: params
            }));

          case 1:
          case "end":
            return _context20.stop();
        }
      }
    }, _callee20);
  }));
  return _copyRole.apply(this, arguments);
}

export function copyOrganizationRole(_x27, _x28) {
  return _copyOrganizationRole.apply(this, arguments);
}
/**
 * 继承并创建角色
 * @async
 * @function inheritRole
 * @param {!object} params - 保存参数
 * @returns {object} fetch Promise
 */

function _copyOrganizationRole() {
  _copyOrganizationRole = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(params, organizationId) {
    return _regeneratorRuntime.wrap(function _callee21$(_context21) {
      while (1) {
        switch (_context21.prev = _context21.next) {
          case 0:
            return _context21.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(organizationId, "/roles/copy"), {
              method: 'POST',
              body: params
            }));

          case 1:
          case "end":
            return _context21.stop();
        }
      }
    }, _callee21);
  }));
  return _copyOrganizationRole.apply(this, arguments);
}

export function inheritRole(_x29) {
  return _inheritRole.apply(this, arguments);
}
/**
 * 继承并创建角色 - 租户级
 * @async
 * @function inheritOrganizationRole
 * @param {!number} organizationId - 组织ID
 * @param {!object} params - 保存参数
 * @returns {object} fetch Promise
 */

function _inheritRole() {
  _inheritRole = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(params) {
    return _regeneratorRuntime.wrap(function _callee22$(_context22) {
      while (1) {
        switch (_context22.prev = _context22.next) {
          case 0:
            return _context22.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/roles/inherit"), {
              method: 'POST',
              body: params
            }));

          case 1:
          case "end":
            return _context22.stop();
        }
      }
    }, _callee22);
  }));
  return _inheritRole.apply(this, arguments);
}

export function inheritOrganizationRole(_x30, _x31) {
  return _inheritOrganizationRole.apply(this, arguments);
}
/**
 * 取消回收角色权限
 * @async
 * @function unrevoke
 * @param {!number} roleId - 角色ID
 * @param {!object} params - 保存参数
 * @returns {object} fetch Promise
 */

function _inheritOrganizationRole() {
  _inheritOrganizationRole = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(params, organizationId) {
    return _regeneratorRuntime.wrap(function _callee23$(_context23) {
      while (1) {
        switch (_context23.prev = _context23.next) {
          case 0:
            return _context23.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(organizationId, "/roles/inherit"), {
              method: 'POST',
              body: params
            }));

          case 1:
          case "end":
            return _context23.stop();
        }
      }
    }, _callee23);
  }));
  return _inheritOrganizationRole.apply(this, arguments);
}

export function unrevoke(_x32, _x33) {
  return _unrevoke.apply(this, arguments);
}
/**
 * 取消回收角色权限 - 租户级
 * @async
 * @function unrevokeOrganization
 * @param {!number} organizationId - 组织ID
 * @param {!number} roleId - 角色ID
 * @param {!object} params - 保存参数
 * @returns {object} fetch Promise
 */

function _unrevoke() {
  _unrevoke = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(roleId, params) {
    return _regeneratorRuntime.wrap(function _callee24$(_context24) {
      while (1) {
        switch (_context24.prev = _context24.next) {
          case 0:
            return _context24.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/role-permissions/").concat(roleId, "/unrevoke"), {
              method: 'POST',
              body: params
            }));

          case 1:
          case "end":
            return _context24.stop();
        }
      }
    }, _callee24);
  }));
  return _unrevoke.apply(this, arguments);
}

export function unrevokeOrganization(_x34, _x35, _x36) {
  return _unrevokeOrganization.apply(this, arguments);
}

function _unrevokeOrganization() {
  _unrevokeOrganization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(roleId, params, organizationId) {
    return _regeneratorRuntime.wrap(function _callee25$(_context25) {
      while (1) {
        switch (_context25.prev = _context25.next) {
          case 0:
            return _context25.abrupt("return", request("".concat(CPAAS_IAM, "/cpaas/v1/").concat(organizationId, "/role-permissions/").concat(roleId, "/unrevoke"), {
              method: 'POST',
              body: params
            }));

          case 1:
          case "end":
            return _context25.stop();
        }
      }
    }, _callee25);
  }));
  return _unrevokeOrganization.apply(this, arguments);
}

export function queryRoleAuth(_x37) {
  return _queryRoleAuth.apply(this, arguments);
}

function _queryRoleAuth() {
  _queryRoleAuth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(params) {
    var roleId, body;
    return _regeneratorRuntime.wrap(function _callee26$(_context26) {
      while (1) {
        switch (_context26.prev = _context26.next) {
          case 0:
            roleId = params.roleId, body = params.body;
            return _context26.abrupt("return", request("".concat(CPAAS_IAM, "/v1/roles/").concat(roleId, "/role-auths"), {
              method: 'GET',
              query: body
            }));

          case 2:
          case "end":
            return _context26.stop();
        }
      }
    }, _callee26);
  }));
  return _queryRoleAuth.apply(this, arguments);
}

export function saveRoleAuth(_x38) {
  return _saveRoleAuth.apply(this, arguments);
}

function _saveRoleAuth() {
  _saveRoleAuth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27(params) {
    var roleId, body;
    return _regeneratorRuntime.wrap(function _callee27$(_context27) {
      while (1) {
        switch (_context27.prev = _context27.next) {
          case 0:
            roleId = params.roleId, body = params.body;
            return _context27.abrupt("return", request("".concat(CPAAS_IAM, "/v1/roles/").concat(roleId, "/role-auths"), {
              method: 'POST',
              body: body
            }));

          case 2:
          case "end":
            return _context27.stop();
        }
      }
    }, _callee27);
  }));
  return _saveRoleAuth.apply(this, arguments);
}

export function deleteRoleAuth(_x39) {
  return _deleteRoleAuth.apply(this, arguments);
}

function _deleteRoleAuth() {
  _deleteRoleAuth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28(params) {
    var roleId, body;
    return _regeneratorRuntime.wrap(function _callee28$(_context28) {
      while (1) {
        switch (_context28.prev = _context28.next) {
          case 0:
            roleId = params.roleId, body = params.body;
            return _context28.abrupt("return", request("".concat(CPAAS_IAM, "/v1/roles/").concat(roleId, "/role-auths?").concat(qs.stringify({
              roleAuthId: body.roleAuthId
            })), {
              method: 'DELETE',
              body: body
            }));

          case 2:
          case "end":
            return _context28.stop();
        }
      }
    }, _callee28);
  }));
  return _deleteRoleAuth.apply(this, arguments);
}